
//初始化数据
$(function() {
	//根据二级分类查询同分类
	var zjid = getQueryString("zjid");
	var fflid = getQueryString("fflid");
	var action3 = "/appsfenlei/selectSFenleiTwo.ph?fflid="+fflid+"";
	ajaxWeb(action3, null, function(data3) {
		var obj = data3.resobj;
		var tr = "";
		for(var i=0;i<obj.length;i++) {
			if(obj[i].zjid==zjid) {
				$("#zjid_").val(obj[i].zjid);
				tr += "<li id=\"li"+i+"\" class=\"li_ on\" onclick=\"chaxun('"+obj[i].zjid+"','1','"+i+"');\"><a href=\"javascript:void(0);\">"+obj[i].name+"</a></li>";
			}else {
				tr += "<li id=\"li"+i+"\" class=\"li_\" onclick=\"chaxun('"+obj[i].zjid+"','1','"+i+"');\"><a href=\"javascript:void(0);\">"+obj[i].name+"</a></li>";
			}
		}
		$("#menu_").html(tr);
	},'json')
	
	//获取视频内容
	var map = {};
	map["fflid"]=zjid;
	map["type"]="1";
	map["page"] = $("#pageIndex").html();
	var action4 = "/appsfenlei/selectSFenleikc.ph";
	var tr = "";
	ajaxWeb(action4, map, function(data4) {
		var obj = data4.resobj.rows;
		for(var i=0;i<obj.length;i++) {
			tr += "<li>";
			tr += "<a href=\"kechengjieshao.html?zjid="+obj[i].zjid+"&\">";
			tr += "<div class=\"pic\">";
			var updatetime = obj[i].updatetime;
			if(updatetime) {
				tr += "<p class=\"f-txt\"><span>"+updatetime.substr(0,10)+"</span><span>更新</span><span>共"+obj[i].jishu+"集</span></p>";
			}else {
				tr += "<p class=\"f-txt\"><span></span><span></span><span>共"+obj[i].jishu+"集</span></p>";
			}
			tr += "<img src=\""+obj[i].imgpcurl+"\" alt=\"\">";
			tr += "</div>";
			tr += "<p class=\"tit\">"+obj[i].name+"</p>";
			tr += "<p class=\"quantity\">"+obj[i].bofangliang+"</p>";
			tr += "</a>";
			tr += "</li>";
		}
		$("#ke-con").html(tr);
		pageStr(data4,"pageDiv");
	},'json')
	
	//相关推荐
	var maps = {};
	maps["zjid"]=fflid;
	maps["index"]=7;
	var actions = "/appSShipin/selectSp.ph";
	var span = "";
	ajaxWeb(actions, maps, function(datas) {
		if(datas.code=="40000") {
			var objs = datas.resobj.rows;
			span += "<h3 class=\"lm-tit1 pt10 pb10\"><span>推荐视频</span><a href=\"gengduoshipin.html?zjid="+fflid+"\">更多</a></h3>";
			span += "<div class=\"m-more\">";
			span += "<div class=\"ul-video\" style=\"margin-left:0px;\">";
			span += "<ul>";
			for(var i=0;i<objs.length;i++) {
				var action1 = "/appsfenlei/selectSFenleiByzjid.ph?zjid="+objs[i].kcid+"";
				ajaxPostAsyncData(action1, null, function(data1) {
					span += "<li style=\"margin-left:10px;\"><a href=\"kechengxiangqing.html?zjid="+objs[i].zjid+"&kcid="+objs[i].kcid+"\"><img style=\"width:100%\" src=\""+data1.resobj.imgpcurl+"\" alt=\"\"><p>"+objs[i].name+"</p></a></li>";
				},'json')
			}
			span += "</ul>";
			span += "</div>";
			span += "</div>";
			$(".tj_").html(span);
		}
	},'json')
});

//查询视频内容
function chaxun(zjid,type,index) {
	if(index) {
		$(".li_").removeClass("on");
		$("#li"+index+"").addClass("on");
	}
	$("#zjid_").val(zjid);
	//获取视频内容
	var map = {};
	map["fflid"]=zjid;
	map["type"]=type;
	map["page"] = $("#pageIndex").html();
	var action3 = "/appsfenlei/selectSFenleikc.ph";
	var tr = "";
	ajaxWeb(action3, map, function(data3) {
		var obj = data3.resobj.rows;
		for(var i=0;i<obj.length;i++) {
			tr += "<li>";
			tr += "<a href=\"kechengjieshao.html?zjid="+obj[i].zjid+"\">";
			tr += "<div class=\"pic\">";
			var updatetime = obj[i].updatetime;
			if(updatetime) {
				tr += "<p class=\"f-txt\"><span>"+updatetime.substr(0,10)+"</span><span>更新</span><span>共"+obj[i].jishu+"集</span></p>";
			}else {
				tr += "<p class=\"f-txt\"><span></span><span></span><span>共"+obj[i].jishu+"集</span></p>";
			}
			tr += "<img src=\""+obj[i].imgpcurl+"\" alt=\"\">";
			tr += "</div>";
			tr += "<p class=\"tit\">"+obj[i].name+"</p>";
			tr += "<p class=\"quantity\">"+obj[i].bofangliang+"</p>";
			tr += "</a>";
			tr += "</li>";
		}
		$("#ke-con").html(tr);
		pageStr(data3,"pageDiv");
	},'json')
}

//按条件查询
function tjchaxun(type,index) {
	$(".lm-tit2 .r a").removeClass("on");
	$(".dian"+index+"_").addClass("on");
	var zjid = $("#zjid_").val();
	//获取视频内容
	var map = {};
	map["fflid"]=zjid;
	map["type"]=type;
	map["page"] = $("#pageIndex").html();
	var action3 = "/appsfenlei/selectSFenleikc.ph";
	var tr = "";
	ajaxWeb(action3, map, function(data3) {
		var obj = data3.resobj.rows;
		for(var i=0;i<obj.length;i++) {
			tr += "<li>";
			tr += "<a href=\"kechengjieshao.html?zjid="+obj[i].zjid+"\">";
			tr += "<div class=\"pic\">";
			var updatetime = obj[i].updatetime;
			if(updatetime) {
				tr += "<p class=\"f-txt\"><span>"+updatetime.substr(0,10)+"</span><span>更新</span><span>共"+obj[i].jishu+"集</span></p>";
			}else {
				tr += "<p class=\"f-txt\"><span></span><span></span><span>共"+obj[i].jishu+"集</span></p>";
			}
			tr += "<img src=\""+obj[i].imgpcurl+"\" alt=\"\">";
			tr += "</div>";
			tr += "<p class=\"tit\">"+obj[i].name+"</p>";
			tr += "<p class=\"quantity\">"+obj[i].bofangliang+"</p>";
			tr += "</a>";
			tr += "</li>";
		}
		$("#ke-con").html(tr);
		pageStr(data3,"pageDiv");
	},'json')
}

function loadData(){
	var zjid = getQueryString("zjid");
	//获取视频内容
	var map = {};
	map["fflid"]=zjid;
	map["type"]="1";
	map["page"] = $("#pageIndex").html();
	var action4 = "/appsfenlei/selectSFenleikc.ph";
	var tr = "";
	ajaxWeb(action4, map, function(data4) {
		var obj = data4.resobj.rows;
		for(var i=0;i<obj.length;i++) {
			tr += "<li>";
			tr += "<a href=\"kechengjieshao.html?zjid="+obj[i].zjid+"&\">";
			tr += "<div class=\"pic\">";
			var updatetime = obj[i].updatetime;
			if(updatetime) {
				tr += "<p class=\"f-txt\"><span>"+updatetime.substr(0,10)+"</span><span>更新</span><span>共"+obj[i].jishu+"集</span></p>";
			}else {
				tr += "<p class=\"f-txt\"><span></span><span></span><span>共"+obj[i].jishu+"集</span></p>";
			}
			tr += "<img src=\""+obj[i].imgpcurl+"\" alt=\"\">";
			tr += "</div>";
			tr += "<p class=\"tit\">"+obj[i].name+"</p>";
			tr += "<p class=\"quantity\">"+obj[i].bofangliang+"</p>";
			tr += "</a>";
			tr += "</li>";
		}
		$("#ke-con").html(tr);
		pageStr(data4,"pageDiv");
	},'json')
	
}